Skip to content

[improve][test] Fix try-with-resources compile warnings in test code#25429

Merged
merlimat merged 4 commits intoapache:masterfrom
merlimat:fix-test-warnings-2
Mar 31, 2026
Merged

[improve][test] Fix try-with-resources compile warnings in test code#25429
merlimat merged 4 commits intoapache:masterfrom
merlimat:fix-test-warnings-2

Conversation

@merlimat
Copy link
Copy Markdown
Contributor

Motivation

Fix try compiler warnings in test code — auto-closeable resources that are not properly handled in try-with-resources statements.

This is part of a series to clean up test compile warnings (following production code cleanup in #25414-#25422).

Changes

  • Category 1: Resources whose close() throws InterruptedException — cannot be used in try-with-resources without catching checked exception; add @SuppressWarnings("try") at method level
  • Category 2: Auto-closeable resources assigned but never referenced — rename to ignored or suppress with @SuppressWarnings("try")

Affected modules: pulsar-broker, pulsar-broker-common, pulsar-common, pulsar-client, pulsar-functions, managed-ledger, and others (~28 files).

Verifying this change

  • ./gradlew compileTestJava passes cleanly
  • try warning count drops to zero

Does this pull request potentially affect one of the following areas?

  • Test code only

Documentation

  • doc-not-needed — test-only changes

Suppress [try] warnings across test code:
- Add @SuppressWarnings("try") for auto-closeable resources whose
  close() throws InterruptedException (PulsarSslFactory, BookKeeper,
  ZooKeeper, PulsarTestContext, etc.)
- Rename unreferenced try-with-resources variables to 'ignored'
- Add @SuppressWarnings("try") for intentionally unreferenced
  auto-closeable resources used for side effects
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Mar 29, 2026
@merlimat merlimat merged commit a7204e0 into apache:master Mar 31, 2026
42 checks passed
@merlimat merlimat deleted the fix-test-warnings-2 branch March 31, 2026 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs ready-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants